<%@ page language="java" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE html>
<html>
<head>
    <title>请选择复制到哪个节点下面</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="${basePath}/component/JQueryzTreev3.5.14/css/zTreeStyle/zTreeStyle.css"
          type="text/css">
    <script type="text/javascript" src="${basePath}/resources/jquery/jquery-1.6.4.min.js"></script>
    <script type="text/javascript" src="${basePath}/component/JQueryzTreev3.5.14/js/jquery.ztree.core-3.5.js"></script>
    <script type="text/javascript">
        <!--
        var setting = {
            data: {
                simpleData: {
                    enable: true
                }
            },
            async: {
                enable: true,
                type:"get",
                dataType:"json",
                url:"<%=basePath%>s/szgz/menu/tree",
                autoParam:["id=upMenuId"],
                dataFilter: ajaxDataFilter
            },
            callback: {
                beforeClick: zTreeBeforeClick,
                onAsyncSuccess: onAsyncSuccess
            }
        };
        function ajaxDataFilter(treeId, parentNode, responseData) {
            var zNodes = new Array();
            for(var i = 0; i < responseData.length; i++){
                var zNode = changeToZtreeNode(responseData[i]);
                zNodes.push(zNode);
            }
            return zNodes;
        };
        function changeToZtreeNode(treeNode){
            var zNode = {};
            zNode.id = treeNode.id;
            zNode.pId = treeNode.parentid;
            zNode.name = treeNode.text;
            if(treeNode.childCount > 0){
                zNode.isParent = true;
            }
            return zNode;
        }
        function zTreeBeforeClick(treeId, treeNode, clickFlag) {
            window.parent.document.getElementById('menuContentFrame').src='<%=basePath%>id/idMenu-input.action?wid='+treeNode.id;
        };
        function onAsyncSuccess(event, treeId, treeNode, msg) {
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            var nodes = treeObj.getNodes();
            if (nodes.length>0) {
                treeObj.expandNode(nodes[0], true, false, false);//展开第一层
            }
        }

        $(document).ready(function(){
            $.fn.zTree.init($("#treeDemo"), setting);
        });
        //-->
    </script>
</head>

<body style="padding-top: 1%;">
<div class="zTreeDemoBackground left">
    <ul id="treeDemo" class="ztree"></ul>
</div>
</body>
</html>
